package com.github.zhijieqing.socket.cluster.common.manager;


import com.github.zhijieqing.socket.cluster.common.channel.MsgChannel;
import com.github.zhijieqing.socket.cluster.common.config.SocketClusterConfig;
import com.github.zhijieqing.socket.cluster.common.domain.SocketMsg;
import com.github.zhijieqing.socket.cluster.common.listener.MessageListener;
import com.github.zhijieqing.socket.cluster.common.node.SocketServerNode;
import com.github.zhijieqing.socket.cluster.common.storage.ClientStorage;

import javax.websocket.Session;
import java.util.Collection;
import java.util.List;

public interface SocketManager {
    void init();
    void put(String clientId, String sessionId);
    void put(String clientId, Session session);
    Collection<SocketServerNode> getServerNodeByClientId(String clientId);
    List<Session> getWsSession(String clientId);
    void removeSession(String sessionId);
    void removeAll(String clientId);
    void removeCurrentNode(String clientId);
    void remove(String clientId,Session session);
    void sendMessage(String clientId, SocketMsg msg);
    void sendMessageCurrentFirst(String clientId, SocketMsg msg);
    void sendMessage(String clientId, String topic, Object payload);
    void sendMessage(String clientId, Object payload);
    void sendMessage(SocketMsg msg);
    void setMsgChannel(MsgChannel msgChannel);
    MsgChannel getMsgChannel();
    void setClientStorage(ClientStorage clientStorage);
    ClientStorage getClientStorage();
    SocketServerNode getCurrentServerNode() ;
    <M> void addListener(Class<M> type, MessageListener<M> listener);
    void onMessage(SocketMsg msg);
    SocketClusterConfig getSocketClusterConfig();
    void setSocketClusterConfig(SocketClusterConfig socketClusterConfig);
}
